package com.leyou.controller;

import com.leyou.dto.AliOssSignatureDTO;
import com.leyou.service.AliAuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author jshstart
 * @creat 2020-12-10 15:18
 */
//@RestController
//@RequestMapping("/ali")
//public class AliAuthController {
//    @Autowired
//    private AliAuthService aliAuthService;
//    @GetMapping("/oss/signature")
//    public ResponseEntity<AliOssSignatureDTO> getAllSignature(){
//        return ResponseEntity.ok(aliAuthService.getSignature());
//    }
//}
@RestController
@RequestMapping("ali")
public class AliAuthController {

    private AliAuthService aliAuthService;

    public AliAuthController(AliAuthService aliAuthService) {
        this.aliAuthService = aliAuthService;
    }

    /**
     * 申请oss签名
     *
     * @return 包含签名、图片验证策略等信息
     */
    @GetMapping("/oss/signature")
    public ResponseEntity<AliOssSignatureDTO> getAliSignature() {
        return ResponseEntity.ok(aliAuthService.getSignature());
    }
    @GetMapping("/{imgName}")
    public void deleteImg(@PathVariable("imgName") String imgName){
        aliAuthService.deleteImg(imgName);
    }

}